package eteam.aps.service.impl;

import eteam.aps.common.entity.ParentEntity;
import eteam.aps.mapper.ProtectionOrgDtlMapper;
import eteam.aps.model.entity.ProtectionOrgDtl;
import eteam.aps.service.ProtectionOrgDtlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 保障机构子表业务层
 *
 * @author WMT
 */
@Service
public class ProtectionOrgDtlServiceImpl implements ProtectionOrgDtlService {

    @Autowired
    private ProtectionOrgDtlMapper protectionOrgDtlMapper;

    @Transactional
    @Override
    public int insert(List<ProtectionOrgDtl> orgDtls) {
        return protectionOrgDtlMapper.insert(orgDtls);
    }

    @Transactional
    @Override
    public int deleteByFDtlId(String fDtlId) {
        return protectionOrgDtlMapper.deleteByFDtlId(fDtlId);
    }

    @Transactional
    @Override
    public int deleteByFId(String fId) {
        return protectionOrgDtlMapper.deleteByFId(fId);
    }

    @Transactional
    @Override
    public int update(ProtectionOrgDtl protectionOrgDtl) {
        return protectionOrgDtlMapper.updateOne(protectionOrgDtl);
    }

    @Override
    public List<ProtectionOrgDtl> selectAllByFDtlId(String fDtlId) {
        Map<String,Object> map = new HashMap<>(2);
        map.put("fDtlId",fDtlId);
        map.put("fState", ParentEntity.FSTATE_DELETED);
        return protectionOrgDtlMapper.selectAllByFDtlId(map);
    }

    @Override
    public int countCodeByFDtlId(Map<String, Object> map) {
        return protectionOrgDtlMapper.countCodeByFDtlId(map);
    }

}
